<?php

namespace App\Http\Controllers\ReportForms;

use App\Http\Controllers\BaseController;
use Illuminate\Http\Request;
use App\Models\ReportForms\PriceForms;

class PriceFormsController extends BaseController
{
    public function getprice(Request $request)
    {
        $memberinfo = $this->mangerinfo;
        $isgetall = $request->isgetall ?? 1;
        $type = $request->type ?? 1;

        $list = PriceForms::getList($request, $memberinfo, $isgetall);
        $data = [];
        if (!empty($list)) {
            foreach ($list['list'] as $key => $value) {
                if ($type == 1) {
                    $data[$key]['purchase_price'] = $value['purchase_price'] / 100;
                    $data[$key]['sale_price'] = $value['sale_price'] / 100;
                    $data[$key]['website_price'] = $value['website_price'] / 100;
                    $data[$key]['operate_price'] = $value['operate_price'] / 100;
                    $data[$key]['future_price'] = $value['future_price'] / 100;
                } elseif ($type == 2) {
                    $data[$key]['diff_price'] = $value['diff_price'] / 1000;
                }
                $data[$key]['date'] = $value['date'];
            }
        }
        return response()->json(['code' => '000', 'msg' => '操作成功', 'data' => $data]);
    }
}
